package com.dfec.service.imp;

import java.sql.SQLException;
import java.util.List;

import com.dfec.dao.INewsDao;
import com.dfec.dao.IPraiseDao;
import com.dfec.dao.imp.NewsDaoImp;
import com.dfec.dao.imp.PraiseDaoImp;
import com.dfec.model.Praise;
import com.dfec.service.IPraiseService;

public class PraiseServiceImp implements IPraiseService {
  IPraiseDao pdao=new PraiseDaoImp();
	@Override
	public int updateClickPraise(String phone, String new_id,String addOrdel) throws SQLException {
		// TODO Auto-generated method stub
		if(addOrdel==null) return 0;
		
		//记录点赞人员
		if(addOrdel.equals("1")) {
			return pdao.updateClickPraise(phone, new_id);
		}else {
			//取消点赞需要验证是否点过
			return pdao.delPraiseByNewsIdAndPhone(phone, new_id)?1:0;
		}
		
	}

	@Override
	public List<Praise> getPraisePeopleListByNewsId(String new_id) throws SQLException {
		// TODO Auto-generated method stub
		return pdao.getPraisePeopleListByNewsId(new_id);
	}

	@Override
	public boolean getPraiseByNewsIdAndPhone(String phone, String new_id) throws SQLException {
		// TODO Auto-generated method stub
		return pdao.getPraiseByNewsIdAndPhone(phone, new_id);
	}

	@Override
	public boolean delPraiseByNewsIdAndPhone(String phone, String new_id) throws SQLException {
		// TODO Auto-generated method stub
		return pdao.delPraiseByNewsIdAndPhone(phone, new_id);
	}

}
